/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.cklm.testtask.util;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Valera
 */
public class IdGenerator {

    private AtomicInteger id_gen;

    public IdGenerator(int start) {
        id_gen = new AtomicInteger(start);
    }

    public int getNewId() {
        int id;
        do {
            id = id_gen.get();
        }
        while (!id_gen.compareAndSet(id, id + 1));
        return (id + 1);
    }


}
